/*
 * @Author: zhuxiaoyi
 * @Date: 2023-11-01 14:47:54
 * @LastEditor: zhuxiaoyi
 * @LastEditTime: 2023-11-01 14:48:00
 * @Description: 
 */
const axios = require('axios');

class AxiosRequest {
    constructor(baseURL) {
        this.axiosInstance = axios.create({
            baseURL,
        });
    }

    // 设置请求头
    setHeaders(headers) {
        this.axiosInstance.defaults.headers = headers;
    }

    // 发送 GET 请求
    get(url, params) {
        return this.axiosInstance.get(url, { params });
    }

    // 发送 POST 请求
    post(url, data) {
        return this.axiosInstance.post(url, data);
    }

    // 发送 PUT 请求
    put(url, data) {
        return this.axiosInstance.put(url, data);
    }

    // 发送 DELETE 请求
    delete(url) {
        return this.axiosInstance.delete(url);
    }
}

module.exports = AxiosRequest;
